{% extends "search/base.html" %}
{% from 'includes/common_macros.html' import for_contributors_sidebar %}
{% if advanced %}
  {% set title = _('Advanced Search') %}
  {% set classes = 'advanced_search' %}
{% endif %}

{% block content %}
  <div class="grid_3 hide-mobile">
    {{ for_contributors_sidebar(user, settings.WIKI_DEFAULT_LANGUAGE) }}
  </div>
  <div class="grid_9">
    <div class="content-box cf" id="advanced-search">
      {% if advanced %}
        <h1 class="nomargin">{{ _('Advanced Search') }}</h1>
        <div id="search-tabs">
          <span id="where" style="display: none">{{ search_form.w.data or '' }}</span>
          <ul class="tab-strip cf" id="advanced-search-tabs">
            <li><a title="{{ _('Search the Knowledge Base') }}" class="tablink" href="#kb">{{ _('Knowledge Base') }}</a></li>
            <li><a title="{{ _('Search the Support Questions') }}" class="tablink" href="#support">{{ _('Support Questions') }}</a></li>
            <li><a title="{{ _('Search the Discussion Forums') }}" class="tablink" href="#discussion">{{ _('Discussion Forums') }}</a></li>
          </ul>
          <div id="tab-wrapper">
            <form id="kb" method="get">
              <div class="container inline-label">
                <label for="kb_q">{{ _('Article contains') }}</label>
                <input name="q" class="auto-fill" id="kb_q" placeholder="{{ _('crashes on youtube') }}" value="{{ search_form.q.data or cached_field or '' }}" type="text" />
              </div>

              <div class="container inline-label">
                <label for="{{ search_form.language.name }}">{{ search_form.language.label_tag() }}</label>
                {{ search_form.language }}
              </div>

              <div class="container cf">
                <p>{{ search_form.category.label_tag() }}</p>
                <div class="category checkboxes">
                  {{ search_form.category }}
                </div>
              </div>

              <div class="container cf">
                <p>{{ search_form.product.label_tag() }}</p>
                <div class="product checkboxes">
                  {{ search_form.product }}
                </div>
              </div>

              <div class="container cf">
                <p>{{ search_form.topics.label_tag() }}</p>
                <div class="topics checkboxes">
                  {{ search_form.topics }}
                </div>
              </div>

              <div class="container cf">
                <label class="include_archived radios">
                  {{ search_form.include_archived }}
                  {{ search_form.include_archived.label_tag() }}
                </label>
              </div>

              <div class="container inline-label">
                <label for="{{ search_form.sortby_documents.name }}">{{ search_form.sortby_documents.label_tag() }}</label>
                {{ search_form.sortby_documents }}
              </div>

              {% for hidden in search_form.hidden_fields() if not hidden.name == 'w' %}
                {{ hidden }}
              {% endfor %}
              <input type="hidden" value="1" name="w" />

              <div class="submit">
                <button class="button dark" data-type="submit">{{ pgettext('button', 'Search Mozilla Support') }}</button>
                <a class="button transparent" href="{{ url('search')|urlparams(q=search_form.q.data) }}">{{ _('Use basic search') }}</a>
              </div>
            </form>{# kb #}
            <form method="get" id="support">
              <div class="container inline-label">
                <label for="support_q">{{ _('Post contains') }}</label>
                <input name="q" class="auto-fill" id="support_q" placeholder="{{ _('crashes on youtube') }}" value="{{ search_form.q.data or '' }}" type="text" />
              </div>

              <div class="container cf">
                <p>{{ search_form.is_locked.label_tag() }}</p>
                <div class="is_locked radios">
                  {{ search_form.is_locked }}
                </div>
              </div>

              <div class="container cf">
                <p>{{ search_form.is_archived.label_tag() }}</p>
                <div class="is_archived radios">
                  {{ search_form.is_archived }}
                </div>
              </div>

              <div class="container cf">
                <p>{{ search_form.is_solved.label_tag() }}</p>
                <div class="is_solved radios">
                  {{ search_form.is_solved }}
                </div>
              </div>

              <div class="container cf">
                <p>{{ search_form.has_answers.label_tag() }}</p>
                <div class="has_answer radios">
                  {{ search_form.has_answers }}
                </div>
              </div>

              <div class="container cf">
                <p>{{ search_form.has_helpful.label_tag() }}</p>
                <div class="has_helpful radios">
                  {{ search_form.has_helpful }}
                </div>
              </div>

              <div class="container cf showhide-input inline-label">
                <label for="{{ search_form.num_voted.name }}">{{ search_form.num_voted.label_tag() }}</label>
                {{ search_form.num_voted }}
                <input name="num_votes" type="text" pattern="\d*"
                       value="{{ search_form.num_votes.data or '' }}"
                       title="{{ _('Number of votes. Must be an integer.') }}" />
              </div>

              <div class="container inline-label">
                <label for="{{ search_form.asked_by.name }}">{{ search_form.asked_by.label_tag() }}</label>
                {{ search_form.asked_by }}
              </div>

              <div class="container inline-label">
                <label for="{{ search_form.answered_by.name }}">{{ search_form.answered_by.label_tag() }}</label>
                {{ search_form.answered_by }}
              </div>

              <div class="container inline-label">
                <label for="{{ search_form.q_tags.name }}">{{ search_form.q_tags.label_tag() }}</label>
                {{ search_form.q_tags }}
              </div>
              <p class="helptext below-inline-label">
                {{ _('Note: Searching for "tag1, tag2" returns questions tagged with both tag1 and tag2') }}
              </p>

              <div class="container cf">
                <p>{{ search_form.product.label_tag() }}</p>
                <div class="product checkboxes">
                  {{ search_form.product }}
                </div>
              </div>

              <div class="container cf">
                <p>{{ search_form.topics.label_tag() }}</p>
                <div class="topics checkboxes">
                  {{ search_form.topics }}
                </div>
              </div>

              <div class="container showhide-input inline-label">
                <label for="{{ search_form.created.name }}">{{ search_form.created.label_tag() }}</label>
                {{ search_form.created }}
                <input name="created_date" type="text" value="{{ search_form.created_date.data or '' }}" class="datepicker" title="{{ _('Created date. Format: mm/dd/yy') }}" />
              </div>

              <div class="container showhide-input inline-label">
                <label for="{{ search_form.updated.name }}">{{ search_form.updated.label_tag() }}</label>
                {{ search_form.updated }}
                <input name="updated_date" type="text" value="{{ search_form.updated_date.data or '' }}" class="datepicker" title="{{ _('Updated date. Format: mm/dd/yy') }}" />
              </div>

              <div class="container inline-label">
                <label for="{{ search_form.sortby.name }}">{{ search_form.sortby.label_tag() }}</label>
                {{ search_form.sortby }}
              </div>

              {% for hidden in search_form.hidden_fields() if not hidden.name == 'w' %}
                {{ hidden }}
              {% endfor %}
              <input type="hidden" value="2" name="w" />

              <div class="submit">
                <button class="button dark" data-type="submit">{{ pgettext('button', 'Search Mozilla Support') }}</button>
                <a class="button transparent" href="{{ url('search')|urlparams(q=search_form.q.data) }}">{{ _('Use basic search') }}</a>
              </div>
            </form>{# support #}
            <form method="get" id="discussion">
              <div class="container inline-label">
                <label for="discussion_q">{{ _('Thread contains') }}</label>
                <input name="q" class="auto-fill" id="discussion_q" placeholder="{{ _('crashes on youtube') }}" value="{{ search_form.q.data or '' }}" type="text" />
              </div>

              <div class="container cf">
                <p>{{ search_form.thread_type.label_tag() }}</p>
                <div class="thread-type checkboxes">
                  {{ search_form.thread_type }}
                </div>
              </div>

              <div class="container inline-label">
                <label for="{{ search_form.author.name }}">{{ search_form.author.label_tag() }}</label>
                {{ search_form.author }}
              </div>

              <div class="container showhide-input inline-label">
                <label for="{{ search_form.created.name }}">{{ search_form.created.label_tag() }}</label>
                {{ search_form.created }}
                <input name="created_date" type="text" value="{{ search_form.created_date.data or '' }}" class="datepicker" title="{{ _('Created date. Format: mm/dd/yy') }}" />
              </div>

              <div class="container showhide-input inline-label">
                <label for="{{ search_form.updated.name }}">{{ search_form.updated.label_tag() }}</label>
                {{ search_form.updated }}
                <input name="updated_date" type="text" value="{{ search_form.updated_date.data or '' }}" class="datepicker" title="{{ _('Updated date. Format: mm/dd/yy') }}" />
              </div>

              <div class="container inline-label">
                <label for="{{ search_form.sortby.name }}">{{ search_form.sortby.label_tag() }}</label>
                {{ search_form.sortby }}
              </div>

              <div class="container inline-label">
                <label for="{{ search_form.forum.name }}">{{ search_form.forum.label_tag() }}</label>
                {{ search_form.forum }}
              </div>

              {% for hidden in search_form.hidden_fields() if not hidden.name == 'w' %}
                {{ hidden }}
              {% endfor %}
              <input type="hidden" value="4" name="w" />

              <div class="submit">
                <button class="button dark" data-type="submit">{{ pgettext('button', 'Search Mozilla Support') }}</button>
                <a class="button transparent" href="{{ url('search')|urlparams(q=search_form.q.data) }}">{{ _('Use basic search') }}</a>
              </div>
            </form>{# discussion #}
          </div>{# tab-wrapper #}
        </div>{# search-tabs #}
      {% else %}
        {% from "search/includes/macros.html" import basic_search_form with context %}
        {{ basic_search_form(True) }}
        <a href="{{ url('search.advanced')|urlparams(q=search_form.q.data) }}">{{ _('Use advanced search') }}</a>
      {% endif %}
    </div>
  </div>
{% endblock %}
